/**
 * 
 */
package com.xbjtech.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.xbjtech.model.Store;
import com.xbjtech.model.StoreExample;
import com.xbjtech.model.StoreExample.Criteria;
import com.xbjtech.service.StoreService;

/**
 * @author Administrator
 *
 */
@RestController
@RequestMapping("/store")
public class StoreController {
	
	@Autowired
	StoreService storeService;
	
	@GetMapping("/list")
	public List<Store> list(@RequestParam Long regionId) {
		// 340000     340100     340102
		StoreExample storeExample = new StoreExample();
		Criteria criteria = storeExample.createCriteria();
		criteria.andRegionidLike("3401__");
		if (regionId % 10000 == 0) {
			criteria.andRegionidLike(regionId / 10000 + "____");
		} else if (regionId % 100 == 0) {
			criteria.andRegionidLike(regionId / 100 + "__");
		} else {
			criteria.andRegionidEqualTo(regionId);
		}
		return storeService.list(storeExample);
	}

}
